package com.briup.recognition.service.impl;

import com.briup.recognition.bean.Greenhouse;
import com.briup.recognition.bean.GreenhouseExample;
import com.briup.recognition.dao.GreenhouseMapper;
import com.briup.recognition.service.IGreenhouseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: recognition
 * @description:
 * @author: charles
 * @create: 2021-03-28 15:11
 **/

@Service
public class GreenhouseServiceImpl implements IGreenhouseService {

    @Resource
    private GreenhouseMapper greenhouseMapper;

    @Override
    public List<Greenhouse> query() {
        GreenhouseExample example = new GreenhouseExample();
        // 条件


        return greenhouseMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(Greenhouse greenhouse) {
        if(greenhouse.getId()!=null){
            greenhouseMapper.updateByPrimaryKey(greenhouse);
        } else {
            greenhouseMapper.insert(greenhouse);
        }
    }

    @Override
    public void deleteById(long id) {
        greenhouseMapper.deleteByPrimaryKey(id);
    }
}
